function webuploaderFile(params) {

    var dnd = params.containerId ||'#upload-container',
    fileSizeLimit = params.fileSizeLimit|| (1024 * 1024 * 1024 * 50),
    fileSingleSizeLimit = params.fileSingleSizeLimit || (1024 * 1024  * 500),
    server = params.url,
    uploadList =  params.uploadList || '#uploadList',
    name = params.name || 'name[]';

    var uploader = WebUploader.create({
        auto: true,// 选完文件后，是否自动上传。
        swf: 'https://cdn.bootcss.com/webuploader/0.1.1/Uploader.swf',// swf文件路径
        server: server,// 文件接收服务端。
        dnd: dnd,
        multiple: true, // 选择多个
        chunked: true,// 开起分片上传。
        threads: 1, // 上传并发数。允许同时最大上传进程数。
        method: 'POST', // 文件上传方式，POST或者GET。
        fileSizeLimit: fileSizeLimit, //验证文件总大小是否超出限制, 超出则不允许加入队列。
        fileSingleSizeLimit: fileSingleSizeLimit, //验证单个文件大小是否超出限制, 超出则不允许加入队列。
        fileVal: 'upload', // [默认值：'file'] 设置文件上传域的name。
        name:name // 列表提交的name
    });
    uploader.on('fileQueued', function (file) {
        let html = '<div class="upload-item" id="' + file.id + '"><div class="file_info"><div class="fileName" title="' + file.name + '">' + file.name + '</div><div class="fileSize"><span class="sizeCurrent">1.25MB</span><span>/</span><spanclass="sizeTotal">' + ToSize(file.size) + '</span></div></div><div class="progress"><div class="percentage"><div class="progress_percentage"></div></div><div class="progress_text">等待上传</div></div><div class="operation" data-file_id="' + file.id + '"><span class="btn-delete" title="取消上传"><i class="layui-icon layui-icon-close" aria-hidden="true"></i></span><span class="btn-play" title="开始"> <i class="iconfont icon-play" aria-hidden="true"></i></span><span class="btn-pause" title="暂停"><i class="layui-icon layui-icon-pause" aria-hidden="true"></i></span><span class="btn-retry" title="重试"><i class="layui-icon layui-icon-refresh" aria-hidden="true"></i></span></div></div>';
        $(uploadList).append(html);
        operation();
    });

    uploader.on('uploadProgress', function (file, percentage) {
        let width = $('.progress').width(),
            obj = $('#' + file.id);
            obj.find('.progress').show();
        obj.find('.progress_percentage').width(width * percentage).addClass('success').removeClass('error');
        obj.find('.sizeCurrent').text(ToSize(file.size * percentage));
        obj.find('.btn-pause').show();
        obj.find('.btn-play').hide();
        obj.find('.progress_text').html('传输中');
    });

    uploader.on('uploadSuccess', function (file, response) {
        let obj = $('#' + file.id);
        obj.find('.sizeCurrent').text(ToSize(file.size));
        obj.find('.progress_text').html('<span style="color: green;"> 上传成功</span>');
        obj.find('.operation span').hide();
        obj.find('.btn-delete').show();
        obj.append('<input type="hidden" id="'+ file.id+'hidden" name="'+uploader.options.name +'" >');
        $('#'+ file.id+'hidden').val(JSON.stringify(response.data));
    });

    uploader.on('uploadError', function (file) {
        let obj = $('#' + file.id);
        obj.find('.progress_percentage').addClass('error').removeClass('success');
        obj.find('.progress_text').html('<span style="color: red;"> 上传失败,请点击重试。</span>');
        obj.find('.operation span').hide();
        obj.find('.btn-delete').siblings('.btn-retry').show();
    });
    uploader.on('uploadComplete', function (file) {
        console.log(uploader.getFiles());
    });
    function operation() {
        $('.upload-item .btn-delete').off('click').click(function () {
            // 从文件队列中删除某个文件id
            file_id = $(this).parent('.operation').data('file_id');
            $(this).parents('.upload-item').remove();
            uploader.removeFile(file_id, true); // 从queue中删除
        });
        $('.upload-item .btn-retry').off('click').click(function () {
            uploader.retry($(this).parent('.operation').data('file_id'));
        });
        $('.upload-item .btn-pause').off('click').click(function () {
            uploader.stop(uploader.getFile($(this).parent('.operation').data('file_id')));
            $(this).hide().siblings('.btn-play').show();
        });
        $('.upload-item .btn-play').off('click').click(function () {
            uploader.upload(uploader.getFile($(this).parent('.operation').data('file_id')));
            $(this).hide().siblings('.btn-pause').show();
        });
    }
    function ToSize(a) {
        var d = [" B", " KB", " MB", " GB", " TB", " PB"];
        var e = 1024;
        for (var b = 0; b < d.length; b++) {
            if (a < e) {
                return (b == 0 ? a : a.toFixed(2)) + d[b]
            }
            a /= e
        }
    }
    
}